package org.clever.arkdemo.deepseek;

import okhttp3.*;

import java.io.IOException;

public class DeepSeekDemo {
    public static void main(String[] args) throws IOException {
        String systemmsg =   "一个内容审查员，提取数据内的关键信息，电话、邮箱、手机号、地理位置、邀请码、广告、时间等。 例如输入： 今天天气很好http://www.baidu.com. 如果你想出去玩可以给我打电话12345678975.  关键信息输出: { 'url': 'http://www.baidu.com', 'phone': '12345678975', 'time': '今天'} ";
        String deepseekKey = "sk-9491960b4ece4fb9983e696b849b19a9";
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, String.format("""
                {
                  "messages": [
                      {
                          "content": "%s",
                          "role": "system"
                      },
                      {
                          "content": "给我发个邮件m.vip@qq.com 。",
                           "role": "user"
                      }
                  ],
                    "model": "deepseek-chat",
                      "frequency_penalty": 0,
                      "max_tokens": 2048,
                      "presence_penalty": 0,
                       "response_format": {
                          "type": "text"
                       },
                      "stop": null,
                      "stream": false,
                      "stream_options": null,
                      "temperature": 1,
                      "top_p": 1,
                      "tools": null,
                      "tool_choice": "none",
                      "logprobs": false,
                      "top_logprobs": null
                    }
                """, systemmsg));
        Request request = new Request.Builder()
                .url("https://api.deepseek.com/chat/completions")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .addHeader("Authorization", "Bearer " + deepseekKey)
                .build();
        try (Response response = client.newCall(request).execute();) {
            String string = response.body().string();
            System.out.println(string);
        }


    }
}
